// 实名认证页面
<template>
  <div style="height:800px">
    <div class="clearfix containerMessage">
      <div class="back">
        <span style="margin-left:10px;" @click="back">返回</span>
      </div>
      <div class="title">
        <span>实名认证</span>
      </div>
    </div>
    <div class="phoneContainer clearfix">
      <div class="clearfix itemConfirm">
        <div class="label">真实姓名：</div>
        <div class="phoneContent">
          <el-input v-model="input" placeholder="请输入内容" size="small"></el-input>
        </div>
      </div>
      <div class="clearfix itemConfirm">
        <div class="label" style="margin-top:10px">手机号：</div>
        <div class="phoneContent">
          <el-input v-model="input" placeholder="请输入内容" size="small"></el-input>
        </div>
        <div class="phoneContent">
          <span>修改</span>
        </div>
      </div>
      <div class="clearfix itemConfirm">
        <div class="label" style="margin-top:10px">身份证号：</div>
        <div class="phoneContent">
          <el-input v-model="input" placeholder="请输入内容"></el-input>
        </div>
      </div>
      <div class="clearfix itemConfirm">
        <div class="label" style="margin-top:10px">身份证正面：</div>
        <div>
          <el-upload class="avatar-uploader" action="https://jsonplaceholder.typicode.com/posts/" :show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
            <img v-if="imageUrl" :src="imageUrl" class="avatar">
            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
          </el-upload>
        </div>
      </div>
      <div class="clearfix itemConfirm">
        <div class="label" style="margin-top:10px">身份证反面：</div>
        <div>
          <el-upload class="avatar-uploader" action="https://jsonplaceholder.typicode.com/posts/" :show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
            <img v-if="imageUrl" :src="imageUrl" class="avatar">
            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
          </el-upload>
        </div>
      </div>
      <div style="margin-top:20px;margin-left:auto;margin-right:auto;width:220px;" class="clearfix">
        <el-button type="primary" round style="display:block;width:100px;float:left;background-color:#01B49E;border:0px;" @click="next">下一步</el-button>
      </div>
    </div>
  </div>
</template>
<style scoped>
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}

.avatar {
  width: 178px;
  height: 178px;
  display: block;
}

.label {
  float: left;
  width: 100px;
  text-align: right;
}

.title {
  margin: auto;
  width: 33.3333333%;
  text-align: center;
  margin-top: 10px;
  float: left;
  font-size: 20px;
  color: white;
}

.back {
  width: 33.3333333%;
  float: left;
  margin-top: 10px;
  text-align: left;
  font-size: 20px;
  color: white;
}

.containerMessage {
  background-color: #01B49E;
  height: 50px;
}

.phoneContent {
  float: left;
  width: 200px;
  height: 32px;
  margin-left: 20px;
  text-align: left;
}

.clearfix::after,
.clearfix::before {
  content: '';
  display: table;
  clear: both;
}

.phoneContainer {
  background-color: #D9EDEB;
}

.itemConfirm {
  margin-top: 20px;
  width: 600px;
  margin-left: 50px;
}
</style>
<script>
export default {
  data() {
    return {
      imageUrl: ''
    }
  },
  methods: {
    back: function() {
      this.$router.go(-1)
    },
    next: function() {
    },
    cancel: function() {
      this.$router.go(-2)
    },
    handleAvatarSuccess(res, file) {
      this.imageUrl = URL.createObjectURL(file.raw)
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === 'image/jpeg'
      const isLt2M = file.size / 1024 / 1024 < 2

      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 格式!')
      }
      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 2MB!')
      }
      return isJPG && isLt2M
    }
  }
}
</script>
